package com.suse.service.view.edu.controller;

import com.suse.common.config.response.R;
import com.suse.service.view.edu.model.entity.Course;
import com.suse.service.view.edu.model.entity.Teacher;
import com.suse.service.view.edu.service.CourseService;
import com.suse.service.view.edu.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 首页前端控制器
 * </p>
 *
 * @author 辜玉彬
 * @since 2022-08-18 11:09
 */
@Api(tags = "首页接口")
@RestController
@RequestMapping("/index")
public class IndexController {

    @Resource
    private CourseService courseService;

    @Resource
    private TeacherService teacherService;

    @ApiOperation(value = "获取首页数据")
    @GetMapping("/data")
    public R getIndexData() {
        // 获取热门课程列表
        List<Course> courseList = courseService.getHotCourseList();
        // 获取推荐讲师列表
        List<Teacher> teacherList = teacherService.getRecommendTeacherList();
        return R.put("courseList",courseList).put("teacherList",teacherList).success();
    }

}
